package com.hue.springbooteasyexcel.service.impl;

import com.alibaba.excel.EasyExcel;
import com.hue.springbooteasyexcel.connector.ImportExcel;
import com.hue.springbooteasyexcel.domain.LineLossAnalyzeExcelVo;
import com.hue.springbooteasyexcel.listener.ExcelListener;
import com.hue.springbooteasyexcel.service.CourtsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * @author 姚凤桥
 * @Date 2022/1/18 9:07
 * @Description:
 */
@Service
public class CourtsServiceImpl implements CourtsService, ImportExcel<LineLossAnalyzeExcelVo> {
    @Autowired
    private ExcelListener<LineLossAnalyzeExcelVo> listener;

    @Override
    public void importUser(MultipartFile file) throws IOException {
        InputStream is = file.getInputStream();
        EasyExcel easyExcel = new EasyExcel();
        easyExcel.read(is, LineLossAnalyzeExcelVo.class, listener).sheet().headRowNumber(3).doRead();
    }

    @Override
    public void importExcel(List<LineLossAnalyzeExcelVo> list) {
        for (LineLossAnalyzeExcelVo lineLossAnalyzeExcelVo : list) {
            System.out.println(lineLossAnalyzeExcelVo);
        }
    }
}
